from Base.Base import Base
from selenium.webdriver.common.by import By
from Common.Api_client import ApiClient
import time
class Page4_operator_add(Base):
    def __init__(self, driver):
        super().__init__(driver)
        self.client = ApiClient()

    # 角色管理模块
    def click_role(self):
        by, value = self.client.get_locator("role", "role_loc")
        self.click((by, value))
    # 角色添加按钮
    def click_role_add(self):
        by, value = self.client.get_locator("role", "role_add_loc")
        self.click((by, value))
    # 角色名称
    def send_role_name(self, roleName):
        by, value = self.client.get_locator("role", "role_name_loc")
        self.send_keys((by, value), roleName)
    # 角色编码
    def send_role_code(self, roleCode):
        by, value = self.client.get_locator("role", "role_code_loc")
        self.send_keys((by, value), roleCode)
    # 角色描述
    def send_role_remark(self, remark):
        by, value = self.client.get_locator("role", "role_remark_loc")
        self.send_keys((by, value), remark)
    # 角色保存按钮
    def click_role_sava(self):
        by, value = self.client.get_locator("role", "role_sava_loc")
        self.click((by, value))
    # 分配菜单
    def click_fen_meun(self):
        by, value = self.client.get_locator("role", "fen_meun_loc")
        self.click((by, value))

    # 勾选分配菜单
    def click_gou_menu(self):
        by1, value1 = self.client.get_locator("role", "menu_quan_loc")
        self.click((by1, value1))
        self.click((by1, value1))
        by2, value2 = self.client.get_locator("role", "gou_menu_loc")
        self.click((by2, value2))
    # 分配菜单保存
    def click_fen_save(self):
        by, value = self.client.get_locator("role", "fen_save_loc")
        self.click((by, value))
    # 分配权限
    def click_fen_pms(self):
        by, value = self.client.get_locator("role", "fen_pms_loc")
        self.click((by, value))
    # 勾选权限
    def click_gou_pms(self):
        by1, value1 = self.client.get_locator("role", "pms_quan_loc")
        self.click((by1, value1))
        self.click((by1, value1))
        by2, value2 = self.client.get_locator("role", "gou_pms_loc")
        self.click((by2, value2))
    # 权限分配保存
    def click_fen_pms_save(self):
        by, value = self.client.get_locator("role", "fen_pms_save_loc")
        self.click((by, value))

    # 操作员模块
    def click_operator(self):
        by, value = self.client.get_locator("operator", "operator_loc")
        self.click((by, value))
    # 添加操作员按钮
    def click_operator_add_btn(self):
        by, value = self.client.get_locator("operator", "operator_add_btn_loc")
        self.click((by, value))
    # 放大
    def alter_max(self):
        by, value = self.client.get_locator("operator", "alter_max_loc")
        self.click((by, value))
    # 输入操作员姓名
    def send_realName(self,realName):
        by, value = self.client.get_locator("operator", "realName_loc")
        self.send_keys((by, value), realName)
    # 输入操作员登录名  要求为邮箱格式
    def send_loginName(self,loginName):
        by, value = self.client.get_locator("operator", "loginName_loc")
        self.send_keys((by, value), loginName)
    # 输入密码
    def send_loginPwd(self,loginPwd):
        by, value = self.client.get_locator("operator", "loginPwd_loc")
        self.send_keys((by, value), loginPwd)
    # 输入手机号
    def send_mobileNo(self,mobileNo):
        by, value = self.client.get_locator("operator", "mobileNo_loc")
        self.send_keys((by, value), mobileNo)
    # 选择当前的状态
    # value 值 ACTIVE,UNACTIVE
    def chose_status(self,value2):
        by1, value1 = self.client.get_locator("operator", "status1_loc")
        self.click((by1, value1))
        time.sleep(2)
        by, value = self.client.get_locator("operator", "status_loc")

        self.select_visible_text((by, value),value2)
    # 输入描述
    def send_remark(self,remark):
        by, value = self.client.get_locator("operator", "remark_loc")
        self.send_keys((by, value), remark)
    # 选择角色
    def click_chose_role(self):
        by, value = self.client.get_locator("operator", "role_loc")
        self.click((by, value))
    # 点击保存按钮
    def click_opertaor_save(self):
        by, value = self.client.get_locator("operator", "save_loc")
        self.click((by, value))
    # 弹窗确定按钮
    def click_que(self):
        by, value = self.client.get_locator("alert", "que_loc")
        self.click((by, value))

    # 弹窗返回内容
    def get_tean_text(self):
        by, value = self.client.get_locator("alert", "tan_text_loc")
        print(by, value)
        return self.get_location_text((by, value))
